-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Committed improvements #35
Conversation
There is Add what you changed to CHANGES.md in the Contributing section of README, but there is no section for this.
Puma can be managed not only via URL with token, but also via CLI without token.
`:restart_timeout` waits this number of seconds before the next restarting the Puma server (default `1`).
Separate commits is fine, thank you! I'll try to review this weekend. I really appreciate the work you put into this project. |
Thank you!
I've switched our commercial project with Puma to Guard, and I've found some troubles with server management via |
CHANGES.md
Outdated
@@ -2,6 +2,7 @@ | |||
|
|||
## master | |||
|
|||
* Don't notify about start when no start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/guard/puma/runner.rb
Outdated
'--environment' => options[:environment] | ||
} | ||
puma_options = { | ||
(pumactl ? '--config-file' : '--config') => options[:config], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of this syntax. I see what it's doing, but I'd prefer something more straightforward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made private constant with keys and private method for getting right key. What do you think?
lib/guard/puma/runner.rb
Outdated
puma_options = { | ||
(pumactl ? '--config-file' : '--config') => options[:config], | ||
'--control-token' => @control_token, | ||
(pumactl ? '--control-url' : '--control') => "tcp://#{@control_url}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This is a bit too clever for my tastes 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also changed.
lib/guard/puma/runner.rb
Outdated
end | ||
[:bind, :threads].each do |opt| | ||
puma_options["--#{opt}"] = options[opt] if options[opt] | ||
%i[bind threads environment].each do |opt| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is there another way these could be checked with out using multiple next
's? I find this kind of imperative looping with conditionals to be difficult to reason about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One next
I took out into Array#select
, but this is double iterating. 🙁
The second next
I deleted with else
adding.
lib/guard/puma/runner.rb
Outdated
end | ||
|
||
def halt | ||
Net::HTTP.get build_uri('halt') | ||
if pumactl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like these can be pushed down a level too so we don't have so many of these conditionals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you.
lib/guard/puma.rb
Outdated
@@ -38,6 +40,8 @@ def start | |||
end | |||
|
|||
def reload | |||
return if Time.now - @last_restarted < options[:restart_timeout] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add parens to make the order of operations more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure.
spec/lib/guard/puma_spec.rb
Outdated
@@ -142,9 +149,13 @@ | |||
end | |||
|
|||
context "with custom :notifications option" do | |||
let(:options) { { notifications: [:restarted] } } | |||
let(:options) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of the Semantic Rule so let's change to {}
instead of do/end
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, no problem.
spec/lib/guard/puma/runner_spec.rb
Outdated
context "without pumactl" do | ||
let(:options) { { pumactl: false } } | ||
|
||
let(:uri) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a proponent of the Semantic Rule for {}
vs do/end
so for the let
's I prefer to use {}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I didn't mean to make this comment twice. I think it came from having 2 browser tabs open for reviews of different commits. Oops!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were many places with let(:foo) do; end
, I replaced all of them.
Thanks @AlexWayfer I'll take a look at this tonight (hopefully) Meant to review it over the weekend but life got in the way. |
Thank you, no problem. Life is important. We can use a fork for a while. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment. Thanks again for all of your contributions!
true => { | ||
config: '--config-file', | ||
control_url: '--control-url' | ||
}.freeze, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These inner hashes don't also need to be frozen. The outer hash being frozen freezes them. ❄️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even Strings in frozen Hashes not frozen, as you can see in this example. So, we maybe should freeze '--config-file'
and other strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, I must have mistyped something in a previous IRB session.
I don't think it's really necessay to deep freeze the whole thing anyway, at least not right now (given no real issues on it)
Hooray! Thank you! 🎉 I'll come back with new changes. 😁 |
Instead of #31, splitted to separate commits.
Sorry, too hard to make separate PRs: one change rely on another.
I can answer ant questions.